class Singleton{
private volatile static Singleton instance = null;
private static Object locker = new Object();
public static Singleton getInstance(){
    if (instance == null){
        synchronized (locker){
            if (instance == null){
                instance = new Singleton();
            }
        }
    }
    return instance;
}
private Singleton(){

    }
}

public class ThreadDemo1 {
    public static void main(String[] args) {

        Singleton singleton1 = Singleton.getInstance();
    }
}
